#include<stdio.h>
#include<stdlib.h>
#define MAX 1000
int h[MAX+1],temp[MAX+1];

int n;
void merge(int l,int r,int mid){               // 两个数组（l-mid）(mid-r) 进行合并
    int  i=l,j=mid+1,k=0;
    while(i<=mid && j<=r)
    {
        if(h[i]<h[j]) temp[k++]=h[i++];
        else temp[k++]=h[j++];
    }
    while(i<=mid) temp[k++]=h[i++];
    while(j<=r) temp[k++]=h[j++];
    for(int i=l,j=0;i<=r;i++,j++)h[i]=temp[j];

}

void merge_sort(int l,int r){
    if(l>=r) return ;
    int mid=l+r>>1;
    merge_sort(l,mid);
    merge_sort(mid+1,r);
    merge(l,r,mid);

}
int main(){
    int k=1;
    FILE *fp,*fo;
    fp=fopen("in.txt","r");
    fo=fopen("out.txt","w");
    fscanf(fp,"%d",&n);
    while(n!=-1)
    {
        
        fprintf(fo,"Case %d : %d\n",k++,n);
       
        for(int i=0;i<n;i++)
        {
            fscanf(fp,"%d",&h[i]); 
        }
        
        merge_sort(0,n-1);
        
       for(int i=0;i<n;i++)
       {
           fprintf(fo,"%d ",h[i]);
       }
        fprintf(fo,"\n");
        fscanf(fp,"%d",&n);
    }
        fclose(fo);
        fclose(fp);

    
}


